package com.beehoo.dcportal.action;

import com.beehoo.dcportal.common.base.BaseAction;
import com.beehoo.dcportal.common.base.BaseException;
import com.beehoo.dcportal.model.CommentBean;
import com.beehoo.dcportal.model.MenuBean;
import com.beehoo.dcportal.model.MessageBean;
import com.beehoo.dcportal.service.ICommentServ;
import com.beehoo.dcportal.service.IMessageServ;
import java.util.List;
import java.util.Map;

public class MessageAction extends BaseAction
{
  private static final long serialVersionUID = 6157526179499236361L;
  private static final String LIST = "list";
  private static final String PICNEWSLIST = "picnewslist";
  private static final String ITEM = "item";
  private IMessageServ msgServ;
  private ICommentServ commentServ;
  private List<MessageBean> msgList;
  private MessageBean msgBean;
  private List<CommentBean> commentList;
  private int totalRows;
  private int pageRows;
  private int pageNo;
  private String action;
  private List<MenuBean> subMenuLs;

  public List<MenuBean> getSubMenuLs()
  {
    return this.subMenuLs;
  }

  public void setSubMenuLs(List<MenuBean> subMenuLs) {
    this.subMenuLs = subMenuLs;
  }

  public String getAction() {
    return this.action;
  }

  public void setAction(String action) {
    this.action = action;
  }

  public int getTotalRows() {
    return this.totalRows;
  }

  public void setTotalRows(int totalRows) {
    this.totalRows = totalRows;
  }

  public int getPageRows() {
    return this.pageRows;
  }

  public void setPageRows(int pageRows) {
    this.pageRows = pageRows;
  }

  public int getPageNo() {
    return this.pageNo;
  }

  public void setPageNo(int pageNo) {
    this.pageNo = pageNo;
  }

  public ICommentServ getCommentServ() {
    return this.commentServ;
  }

  public void setCommentServ(ICommentServ commentServ) {
    this.commentServ = commentServ;
  }

  public List<CommentBean> getCommentList() {
    return this.commentList;
  }

  public void setCommentList(List<CommentBean> commentList) {
    this.commentList = commentList;
  }

  public IMessageServ getMsgServ() {
    return this.msgServ;
  }

  public void setMsgServ(IMessageServ msgServ) {
    this.msgServ = msgServ;
  }

  public List<MessageBean> getMsgList() {
    return this.msgList;
  }

  public void setMsgList(List<MessageBean> msgList) {
    this.msgList = msgList;
  }

  public MessageBean getMsgBean() {
    return this.msgBean;
  }

  public void setMsgBean(MessageBean msgBean) {
    this.msgBean = msgBean;
  }

  public String list()
  {
    try {
      this.pageNo = Integer.parseInt((String)this.paramMap.get("pageNo"));
    } catch (Exception e) {
      this.pageNo = 1;
    }
    this.pageRows = 15;
    this.action = ("/msg/list/" + (String)this.paramMap.get("msgType") + "/" + (String)this.paramMap.get("msgId") + "/");
    try
    {
      setClickedMenu((String)this.paramMap.get("msgType"));

      this.msgList = this.msgServ.getMessageList((String)this.paramMap.get("streetId"), (String)this.paramMap.get("msgType"), this.pageNo, this.pageRows);
      this.totalRows = this.msgServ.getMessageCount((String)this.paramMap.get("streetId"), (String)this.paramMap.get("msgType"));
      this.subMenuLs = getSubMenuList(getCurrMenu().getMenuId());
    } catch (BaseException e) {
      return "error";
    }
    return "list";
  }

  public String picnewslist()
  {
    try {
      this.pageNo = Integer.parseInt((String)this.paramMap.get("pageNo"));
    } catch (Exception e) {
      this.pageNo = 1;
    }
    this.pageRows = 6;
    this.action = ("/msg/picnewslist/" + (String)this.paramMap.get("msgType") + "/" + (String)this.paramMap.get("msgId") + "/");
    try
    {
      setClickedMenu((String)this.paramMap.get("msgType"));

      this.msgList = this.msgServ.getMessageList((String)this.paramMap.get("streetId"), (String)this.paramMap.get("msgType"), this.pageNo, this.pageRows);
     
      this.totalRows = this.msgServ.getMessageCount((String)this.paramMap.get("streetId"), (String)this.paramMap.get("msgType"));
      this.subMenuLs = getSubMenuList(getCurrMenu().getMenuId());
    } catch (BaseException e) {
      return "error";
    }
    return "picnewslist";
  }

  public String item()
  {
    try {
      setClickedMenu((String)this.paramMap.get("msgType"));
      this.msgBean = this.msgServ.getMessageItem((String)this.paramMap.get("streetId"), (String)this.paramMap.get("msgId"));

      if ("0".equals(this.msgBean.getDisEnable())) {
        try {
          this.pageNo = Integer.parseInt((String)this.paramMap.get("pageNo"));
        } catch (Exception e) {
          this.pageNo = 1;
        }
        this.pageRows = 8;
        this.action = ("/msg/item/" + (String)this.paramMap.get("msgType") + "/" + (String)this.paramMap.get("msgId") + "/");

        this.commentList = this.commentServ.getCommentList((String)this.paramMap.get("streetId"), (String)this.paramMap.get("msgId"), this.pageNo, this.pageRows);

        this.totalRows = this.commentServ.getCommentCount((String)this.paramMap.get("streetId"), (String)this.paramMap.get("msgId"));
      }
    } catch (BaseException e) {
      return "error";
    }

    return "item";
  }
}